package com.cc.redis;


import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

public class ClusterTest {

    private static Set<HostAndPort> hpSet = new HashSet<HostAndPort>();

    private static String HOST = "192.168.221.132";

    private static int[] PORTS = {6379, 6380, 6381, 6382, 6383, 6384};

    @org.junit.Before
    public void init() {
        for (int port : PORTS) {
            hpSet.add(new HostAndPort(HOST, port));
        }
    }

    @Test
    public void test() {
        System.out.println(hpSet.size());
        System.out.println(hpSet.iterator().next().getHost());
        System.out.println(hpSet.iterator().next().getPort());
        JedisCluster cluster = new JedisCluster(hpSet, 3);
        cluster.set("k1", "v2");
        System.out.println(" ==== set k1 suc");
        //cluster.get("k1");
        System.out.println("===== get k1:" + cluster.get("k1"));
    }

}
